package cn.com.chengq.swing;

import javax.swing.*;
import java.awt.*;

public class App {
    public static void main(String[] args) {
        // Schedule a job for the event-dispatching thread:
        // Creating and showing this application's GUI.
        // 1. 等效方法调用
        //        javax.swing.SwingUtilities.invokeLater(new Runnable() {
        //            @Override
        //            public void run() {
        //                createAndShowGUI();
        //            }
        //        });
        // 2. 等效方法调用
        // javax.swing.SwingUtilities.invokeLater(() -> createAndShowGUI());
        // 3. 等效方法调用
        javax.swing.SwingUtilities.invokeLater(App::createAndShowGUI);
    }

    /**
     * Create the GUI and show it. For thread safely,
     * this method should be invoked from the event-dispatching thread.
     */
    private static void createAndShowGUI() {
        // Ask for window decorations provided by the look and feel.
        // JFrame.setDefaultLookAndFeelDecorated(true);

        // Create and set up the window.
        JFrame frame = new JFrame("FrameDemo");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        JLabel emptyLabel = new JLabel();
        emptyLabel.setPreferredSize(new Dimension(275, 100));
        frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

        // Display the window
        frame.pack();
        frame.setVisible(true);
    }
}
